<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>class</title>
</head>
<body>

</body>
<script>

    //传统ES5创建类
    function Phone (brand,price){
        this.brand = brand;
        this.price = price;
    }

    //利用对象原型添加方法
    Phone.prototype.call = function (){
        console.log('打电话');
    }
    let phone = new Phone('苹果',9999);
    console.log(phone);
    phone.call();

    //class写法
    class Shouji {
        //构造方法
        constructor(brand,price) {
            this.brand = brand;
            this.price = price;
        }
        call(){
            console.log('拨打电话')
        }
    }

    const shouji = new Shouji('华为',1999);
    console.log(shouji);
    shouji.call();


</script>
</html>